<template>
	<view class="my-service-detail">
		<view class="ms-detail-wrapper">
			<view class="serve-item">
				<view class="serve-master">
					<image :src="$BASE_URL+info.service_banner"></image>
					<view class="master-tit">
						<text>{{info.service_name}}</text>
					</view>
				</view>
				<view class="serve-biaoqian">
					<view class="serve-tags" v-if="info.service_tags">
						<view class="tag-item" v-for="(item1,index1) in info.service_tags.split(',')" :key="index1">{{item1}}</view>
					</view>
				</view>
				<view class="serve-detail-info" v-if="false">
					<view class="detail-info-list flex-between">
						<view class="detail-item">
							<text class="detail-val">9-12个月</text>
							<text class="detail-label">办理周期</text>
						</view>
						<view class="detail-item">
							<text class="detail-val">临时居民</text>
							<text class="detail-label">签证类型</text>
						</view>
						<view class="detail-item">
							<text class="detail-val">166个</text>
							<text class="detail-label">免签国家</text>
						</view>
						<view class="detail-item">
							<text class="detail-val">以香港为家</text>
							<text class="detail-label">居住要求</text>
						</view>
					</view>
				</view>
				<view class="serve-other flex-between">
					<view class="serve-other-star">
						<text>推荐指数</text>
						<up-rate :count="count" v-model="info.service_score" active-color="#FF7139"
							inactive-color="#b2b2b2"></up-rate>
					</view>
					<!-- 	<view class="serve-other-link" @tap="handleSkip(0)">
						<text>点击进入</text>
						<image src="/static/img/serve/more.png"></image>
					</view> -->
				</view>
			</view>
		</view>
		<view class="my-service-content">
			<view class="serve-item">
				<view class="serve-item-header">
					<text class="head-b"></text>
					<text class="item-tit">服务进度</text>
				</view>
				<view class="serve-info">
					<view class="serve-info-taiojian">
						<view class="tiaojian-item" v-for="(item,index) in info.list">
							<up-icon v-if="index==info.list.length-1" name="checkmark-circle-fill" color="#FF7139" size="16"></up-icon>
							<image v-else src="/static/img/serve/itemlogo.png"></image>
							<view class="serve-progress">
								<text class="time">{{item.date}}</text>
								<text class="title">{{item.name}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="serve-item">
				<view class="serve-item-header">
					<text class="head-b"></text>
					<text class="item-tit">合同文件</text>
				</view>
				<view class="serve-info" style="padding-bottom: 200rpx;">
					<view class="order-list">
						<view class="order-item" @click="down">
							<template v-if="info.contract_file_name">
								<view class="order-info">
									<image src="/static/img/my/pf.png"></image>
									<text>{{info.contract_file_name}}</text>
								</view>
								<view class="order-btn">查看</view>
							</template>
							<text v-else>无</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="apply-btn-wrapper" @click="lookDetails">
			<view class="apply-btn">
				<text>查看我的申请信息</text>
			</view>

		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		unref,
		getCurrentInstance
	} from "vue"
	const {
		proxy
	} = getCurrentInstance()
	import {
		onLoad
	} from "@dcloudio/uni-app"
	const count = ref(5)
	const value = ref(4)
	const order_id = ref("")
	const info = ref({})
	onLoad((e)=>{
		order_id.value = e.order_id
		getData()
	})
	function down() {
		preview(proxy.$BASE_URL+info.value.contract_file)
	}
	function lookDetails() {
		if(info.value.service_id==1){
			proxy.go(`/pages/serve/peopleApply/peopleApply?id=${info.value.order_id}`)
		}
		if(info.value.service_id==2){
			proxy.go(`/pages/serve/serveApply?id=${info.value.order_id}`)
		}
		if(info.value.service_id==3){
			proxy.go(`/pages/serve/companyApply/companyApply?id=${info.value.order_id}`)
		}
		if(info.value.service_id==4){
			proxy.go(`/pages/serve/applystartBusiness/applystartBusiness?id=${info.value.order_id}`)
		}
	}
	const preview = (middle) => {
		console.log('middle: ', middle)
			uni.downloadFile({
				url: middle,//middle为调用接口返回的文件地址
				success: (data) => {
					uni.saveFile({ //文件保存到本地
						tempFilePath: data.tempFilePath, //临时路径
						success: function(res) {
							uni.openDocument({
								showMenu: true, //关键点,可以转发到微信
								filePath: res.savedFilePath,
							});
						}
					});
				}
			});
	 
		}
	function getData() {
		proxy.$request({
			url: 'api/User/getMyServiceDetail',
			header: "application/x-www-form-urlencoded",
			data: {order_id:order_id.value}
		}).then(res => {
			if (res.code == 0) {
				return proxy.$toast(res.msg)
			} else {
				res.data.list=[]
				for(let i in res.data.schedule){
					res.data.list.push({
						date:i,
						name:res.data.schedule[i]
					})
				}
				info.value = res.data
			}
		})
	}
</script>

<style lang="scss" scoped>
	.flex-between {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.my-service-detail {
		background: #f8f8f8;
		.ms-detail-wrapper {
			padding: 0 32rpx 20rpx 32rpx;
			background: #fff;

			.serve-item {
				.serve-master {
					position: relative;

					image {
						width: 100%;
						height: 304rpx;
					}

					.master-tit {
						position: absolute;
						left: 0;
						right: 0;
						width: 100%;
						text-align: center;
						top: 0;
						height: 304rpx;
						line-height: 304rpx;

					}

					text {
						font-size: 36rpx;
						font-weight: bold;
						color: #fff
					}

				}
				.serve-biaoqian {
					.serve-tags {
						display: flex;
						justify-content: flex-start;
						align-items: center;
						flex-wrap: wrap;
						margin: 20rpx 0;
				
						.tag-item {
							width: 152rpx;
							height: 60rpx;
							line-height: 60rpx;
							border-radius: 16rpx;
							text-align: center;
							color: #FF9839;
							background: #FFF6EE;
							font-size: 24rpx;
							margin-left: 12rpx;
							margin-bottom: 14rpx;
						}
					}
				}
				
				.serve-detail-info {
					padding: 20rpx;

					.detail-info-list {
						text {
							display: block;
							margin: 8rpx 0;
						}

						.detail-val {
							color: #333;
							font-size: 28rpx;
						}

						.detail-label {
							font-size: 26rpx;
							color: #999
						}
					}

				}

				.serve-other {
					font-size: 24rpx;
					margin-bottom: 24rpx;
					padding: 0 12rpx;
					// height: 32rpx;
					// line-height: 32rpx;

					.serve-other-star {
						display: flex;
						justify-content: flex-start;
						align-items: center;
						color: #333;

						image {
							position: relative;

							width: 32rpx;
							height: 32rpx;
							top: 6rpx;
							left: 6rpx;
							margin-left: 10rpx;
						}


					}

					.serve-other-link {
						color: #999;

						image {
							width: 28rpx;
							height: 28rpx;
							position: relative;
							top: 6rpx;
						}
					}
				}
			}
		}

		.my-service-content {
			margin-top: 20rpx;
			background: #f8f8f8;

			.serve-item {
				background: #fff;
				margin-bottom: 20rpx;
				border-radius: 20rpx;
				padding: 10rpx 32rpx;

				.serve-item-header {
					margin-bottom: 20rpx;

					.head-b {
						display: inline-block;
						width: 12rpx;
						height: 24rpx;
						background: #FF7139;

					}

					.item-tit {
						color: #333333;
						font-weight: bold;
						font-size: 32rpx;
						margin-left: 16rpx;
					}

				}

				.serve-info {
					.order-list {
						width: 100%;

						// display: flex;
						.order-item {
							display: flex;
							justify-content: space-between;
							align-items: center;
							padding: 30rpx 20rpx;
							// height: 88rpx;
							background: #F7F7F7;
							border-radius: 16rpx 16rpx 16rpx 16rpx;
							margin-top: 20rpx;

							image {
								width: 24rpx;
								height: 24rpx;
							}

							text {
								color: #333;
								font-size: 28rpx;
								margin-left: 10rpx;
							}

							.order-btn {
								width: 72rpx;
								height: 36rpx;
								background: #3988FF;
								border-radius: 4rpx 4rpx 4rpx 4rpx;
								font-size: 24rpx;
								color: #fff;
								text-align: center;
								line-height: 36rpx;
							}
						}
					}

					.info-introd {
						color: #666;
						font-size: 28rpx;
						line-height: 32rpx;
					}

					.serve-info-taiojian {
						.tiaojian-item {
							display: flex;
							align-items: center;
							justify-content: flex-start;
							line-height: 64rpx;

							image {
								height: 20rpx;
								width: 20rpx;
								margin-right: 12rpx;
							}

							.title {
								font-size: 28rpx;
								color: #333;
								margin-left: 40rpx;
							}

							.time {
								color: #666;
								font-size: 24rpx;
								padding: 0 20rpx;
							}


						}
					}

					.serve-info-flow {
						image {
							height: 310rpx;
							width: 686rpx
						}

					}

					.serve-info-file {
						.file-list {
							position: relative;
							padding-left: 10rpx;

							.file-item {
								color: #666666;
								font-size: 24rpx;
								line-height: 45rpx;
							}
						}

					}
				}

			}
		}

		.apply-btn-wrapper {
			position: fixed;
			bottom: 0;
			background: #fff;
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			height: 200rpx;

			.apply-btn {
				margin: 0 auto;
				height: 96rpx;
				background: linear-gradient(128deg, #FF9839 0%, #FF7139 100%);
				border-radius: 200rpx;
				width: 686rpx;
				text-align: center;
				font-size: 32rpx;
				color: #fff;
				line-height: 96rpx;
			}

			// background: rgba(0,0,0,);
		}


	}
</style>